package com.hr.requestmapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("user") //RequestMapping 注解可以加在类，上也可以加在方法上
public class UserController {

//    @RequestMapping(value = "login",method = RequestMethod.GET) //user/login   请求方式为get
//    可以设置请求方式，如果使用其他的方式提交则会报405异常，提交方式不允许
//    @RequestMapping("*") //user/login 模糊匹配  //user/*[pi
    @ResponseBody
    @PostMapping("login")// 等同于=@RequestMapping(value = "login",method = RequestMethod.GET)
    public String login(){
        System.out.println("登陆了");
        return "login success";
    }

//    @RequestMapping(value = "user/register",method = RequestMethod.POST)
    @ResponseBody
    @PostMapping("register")
    public String register(){
        System.out.println("开始注册");
        return "resister success";
    }

//    @RequestMapping(value = "index",method = RequestMethod.GET)
    @ResponseBody
    @GetMapping("index")
    public String index(){
        System.out.println("首页");
        return "ok";
    }


}
